Rect = {
  x = 0.0, --从0到1080  归一化（-1，1）
  y = 0.0, --从0到1440  归一化（-1，1）
  width = 0.0, --从0到1080
  height = 0.0, --从0到1440 
  res = nil,
  BASE_WIDTH = 1080.0,
  BASE_HEIGHT = 1920.0,
}
function Rect:new(x, y, width, height,resolution)
  local newRect = {
  }

  setmetatable(newRect, self)
  self.__index = self

  newRect.x = x or 0.0
  newRect.y = y or 0.0
  newRect.width = width or 0.0
  newRect.height = height or 0.0
  newRect.res = resolution

  return newRect
end
function Rect:setResolution(resolution)
        self.res = resolution
end
function Rect:setRect(x,y,width,height)
        self.x = x
        self.y = y
        self.width = width
        self.height = height
end
function Rect:transform()
 -- local ratio = self:is9to16() and 1.0 or 4.0/3.0
 local ratio = 16.0/9.0*self.res.x/self.res.y
  local rx = (self.x - 540.0) / 540.0
  local ry = (self.y - 960.0) / 960.0
  local rwidth = self.width*2 / 1080.0
  local rheight = self.height*2*ratio / 1920.0 --*ratio保证了16:9下和4:3下的高度相同
  return {x=rx,y=ry,width=rwidth,height=rheight}
end
function Rect:is9to16()
  local ratio = self.res.x/self.res.y

  if ratio > 0.5 and ratio < 0.6 then
      return true
  end

  return false
end